/*
 * Wall.fx
 *
 * Created on 19/12/2008, 14:19:18
 */
package socialcampx;

import java.lang.System;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import socialcampx.Constants;
import socialcampx.Metadata;
import socialcampx.Panel;

/**
 * @author 00412804581
 */

public class Wall extends CustomNode {

    package var metadata : Metadata[];

    // When MetaData is inserted, we create a new thumbnail.
    def panels : Panel[] = bind for (newData in metadata) {
        var row = bind (indexof newData) / Constants.POST_COLS;
        var col = bind ((indexof newData) + 1) mod Constants.POST_COLS;

        //delete newData from metadata;
        
        Panel {
            width: bind Constants.POST_WIDTH
            height: bind Constants.POST_HEIGHT
            text: bind newData.text
            image_url: bind newData.image_url
            info: bind newData.info
            translateX: bind (col * Constants.POST_WIDTH) +
                   (col * Constants.POST_HORIZONTAL_SPACING)
            translateY: bind (row * (Constants.POST_HEIGHT + Constants.POST_INFO_HEIGHT)) +
                   (row * (Constants.POST_VERTICAL_SPACING))            
        };        
    }

    override function create() : Node {
        return Group {
            content: bind panels
        }
    }
}
